package com.cleaningcloud.common.security.utils;


import com.cleaningcloud.common.core.utils.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品类型转换
 */
public class CommunityTypeConversionUtils {


    public static String conversion(String communityTypeIds) {
        try {
            List<String> str = new ArrayList<>();
            if (StringUtils.isNotEmpty(communityTypeIds)) {
                for (String s : communityTypeIds.split(",")) {
                    String communityType = CommunityTypeUtils.getCommunityTypeCache(s);
                    if (StringUtils.isNotEmpty(communityType)) {
                        str.add(communityType);
                    }
                }
                return String.join(", ", str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    public static String conversionRegexp(String communityType) {
        if (StringUtils.isNotEmpty(communityType)) {
            List<String> str = new ArrayList<>();
            for (String s : communityType.split("\\|")) {
                str.add("(^|,|)" + s + "(^|,|)");
            }
            return String.join("|", str);
        }
        return null;
    }
}
